import request from '@/utils/request'
import myRequest from '@/utils/myRequest'

export function login(data) {
  return myRequest({
    url: '/api/auth/login',
    method: 'post',
    data
  })
}

export function register(data) {
  return myRequest({
    url: '/api/auth/register',
    method: 'post',
    data
  })
}

export function register_admin(data) {
  return myRequest({
    url: '/api/auth/register_admin',
    method: 'post',
    data
  })
}

export function getRole() {
  return myRequest({
    url: '/api/user/role',
    method: 'get'
  })
}

export function changePassword(old_password, new_password, new_password_confirmed) {
  return myRequest({
    url: '/api/auth/change_password',
    method: 'post',
    params: {
      old_password: old_password,
      new_password: new_password,
      new_password_confirmed: new_password_confirmed
    }
  })
}


export function getInfo(token) {
  return request({
    url: '/vue-element-admin/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/vue-element-admin/user/logout',
    method: 'post'
  })
}
